<?php

namespace App\Providers;

use App\Models\Category;
use App\Models\Config;
use App\Observers\CategoryObserver;
use App\Services\SmsService;
use Barryvdh\LaravelIdeHelper\IdeHelperServiceProvider;
use Illuminate\Http\Resources\Json\JsonResource;
use Illuminate\Pagination\Paginator;
use Illuminate\Support\ServiceProvider;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     *
     * @return void
     */
    public function register()
    {
        if ($this->app->environment() !== 'production') {
            $this->app->register(IdeHelperServiceProvider::class);
        }
    }

    /**
     * Bootstrap any application services.
     *
     * @return void
     */
    public function boot()
    {
//        Schema::defaultStringLength(191);
        JsonResource::withoutWrapping();
        Paginator::useBootstrap();
        $config = Config::find(1);

        \View::share('config', $config ?? null);

        //注册创建修改栏目的观察器
        Category::observe(CategoryObserver::class);
    }
}
